<?php

define('IN_TICKY', true);
define('TICKY_VERSION', '1.0.0');
define('TICKY_START_TIME', microtime(true));
define('TICKY_START_MEM', memory_get_usage());
define('EXT', '.php');
define('DS', DIRECTORY_SEPARATOR);
defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . DS);
defined('ROOT_PATH') or define('ROOT_PATH', dirname(realpath(APP_PATH)) . DS);
defined('TICKY_PATH') or define('TICKY_PATH', __DIR__ . DS); // 定义框架目录
defined('LIB_PATH') or define('LIB_PATH', TICKY_PATH . 'library' . DS);
defined('EXTEND_PATH') or define('EXTEND_PATH', ROOT_PATH . 'extend' . DS);
defined('VENDOR_PATH') or define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS);
defined('RUNTIME_PATH') or define('RUNTIME_PATH', ROOT_PATH . 'runtime' . DS);

defined('PATH') or define('PATH', APP_PATH . DS . 'common'); // 定义公共模块目录
defined('VIEW') or define('VIEW', PATH . DS . 'view'); // 定义公共视图目录
// 环境常量
define('IS_CLI', PHP_SAPI == 'cli' ? true : false);
define('IS_WIN', strpos(PHP_OS, 'WIN') !== false);
//当前文件名
if (IS_CLI) {    //CGI/FASTCGI模式下
    $_temp = explode('.php', $_SERVER['SCRIPT_NAME']);
    define('PHP_FILE', rtrim(str_replace($_SERVER['HTTP_HOST'], '', $_temp[0] . '.php'), '/'));
} else {
    define('PHP_FILE', rtrim($_SERVER['SCRIPT_NAME'], '/'));
}

define('URL_MODEL', '3'); //URL模式: 0=>mca兼容模式，1=>s兼容模式，2=>REWRITE模式，3=>SEO模式。
define('HTTP_REFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); //来源
define('HTTP_HOST', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')); //当前访问的主机名
define('SERVER_PORT', isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://'); //主机协议 http/https
define('SITE_PATH', str_replace('index.php', '', PHP_FILE)); //程序安装路径
define('SITE_URL', SERVER_PORT . HTTP_HOST . SITE_PATH); //程序URL地址
//定义当前请求的系统常量
define('TIMESTAMP', time());
define('NOW_DATE', date('Y-m-d H:i:s'));
if (APP_DEBUG) {
    ini_set("display_errors", "On");
    error_reporting(E_ERROR | E_WARNING | E_PARSE); //报告运行时错误
} else {
    ini_set("display_errors", 'Off');
    error_reporting(0); //禁用错误报告
}
require __DIR__ . '/function/function.php';
require __DIR__ . '/function/function_core.php';
require APP_PATH . '/common/function/function.php';
require LIB_PATH . '/loader.php'; // 载入Loader类
// 注册自动加载
\ticky\loader::register();
\ticky\debug::register();
